import React, { memo } from 'react';
import { useDrag } from 'react-dnd';

export default memo(({ children, type }) => {
    const [{ isDragging }, drag] = useDrag({
        item: { type },
        canDrag: true,
        collect: (monitor) => {
            return {
                isDragging: monitor.isDragging(),
            }
        }
    });
    return (
        React.cloneElement(children, { ref: drag })
    )
});